
function convertSecurityIdToStringAndDropUniverseIds(collection) {
	var operationsCounter = 0;
	var operationsManager = collection.initializeUnorderedBulkOp();
	
	collection.find().forEach(d => {
	    operationsManager.find({_id: d._id}).updateOne({ $set: { SecurityId: d.SecurityId.toString() }});
	    
	    if (++operationsCounter == 1000) { 		
			operationsManager.execute();
			
			operationsManager = collection.initializeUnorderedBulkOp();
			
			operationsCounter = 0;
		}
	});
	
	operationsManager.find({}).update({ $unset: { UniverseIds: 1 }});
	
	operationsManager.execute();
}

var clientPlatformDB = db.getSiblingDB("ClientPlatform");

convertSecurityIdToStringAndDropUniverseIds(clientPlatformDB.PortfolioDetails);

convertSecurityIdToStringAndDropUniverseIds(clientPlatformDB.PortfolioMatches);